package com.raulraja.util.handler.impl;

import com.raulraja.service.BusinessService;
import org.springframework.web.HttpRequestHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Simple handler that invokes the service for demo purposes
 */
public class ServiceInvokerHandlerImpl implements HttpRequestHandler {

	/**
	 * the business service
	 */
	private BusinessService businessService;

	/**
	 * Sets the service
	 * @param businessService the service
	 */
	public void setBusinessService(BusinessService businessService) {
		this.businessService = businessService;
	}

	/**
	 * Process the given request, generating a response.
	 *
	 * @param request  current HTTP request
	 * @param response current HTTP response
	 * @throws javax.servlet.ServletException in case of general errors
	 * @throws java.io.IOException			in case of I/O errors
	 */
	public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		businessService.doSomething();
	}
}
